package sz.szsmk.citizencard.util;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Point;
import android.view.Display;
import android.view.ViewTreeObserver;

import sz.szsmk.citizencard.util.zxyh.DragFloatActionButton;
import sz.szsmk.citizencard.ui.activity.CareModeActivity;

/**
 * Copyright (c)2021/5/11
 * author: hxh
 * created on: 2021/5/11 16:28
 * description:
 */
public class InitBallView {
    private static int flag=0;
    public static void initFloatView(Activity activity, DragFloatActionButton dragFloatActionButton) {
        final ViewTreeObserver vto = dragFloatActionButton.getViewTreeObserver();
        vto.addOnPreDrawListener(() -> {
            // vto.removeOnPreDrawListener(this);
            int width = dragFloatActionButton.getMeasuredWidth();
            Display defaultDisplay = activity.getWindowManager().getDefaultDisplay();
            Point point = new Point();
            defaultDisplay.getSize(point);
            int x = point.x;
            // int rawX = x-width- 30;
            //int rawX = x-width-Utils.dp2px(activity, 18);
            //floatView.setLayout(dragFloatActionButton,rawX,rawY);
            return true;
        });
        dragFloatActionButton.setOnClickListener(() -> {
            Intent intent = new Intent(activity, CareModeActivity.class);
            activity.startActivityForResult(intent,3003);

//                String access_token = ACache.get(activity).getAsString("access_token");
//                if (getAccessToken() == null)
//                    JumpThirdView.baseToJumpView(activity, "https://tyhd.szsmk.com/dingdingkefu/index", "", 0, "");
//                else {
//                    JumpThirdView.baseToJumpView(activity, "https://tyhd.szsmk.com/dingdingkefu/index?access_token=" + access_token, "", 0, "");
//                }
        });

    }
}
